// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#pragma once

#include <turbo/flags/flag.h>
#include <memory>
#include <mutex>

#include <pollux/tpch/gen/dbgen/dss.h>
#include <pollux/tpch/gen/dbgen/dsstypes.h>
#include <pollux/flag_definitions/flags.h>

namespace kumo::pollux::tpch {
    /// This class exposes a thread-safe and reproducible iterator over TPC-H
    /// synthetically generated data, backed by DBGEN.
    class DBGenIterator {
    public:
        explicit DBGenIterator(double scaleFactor);

        // Before generating records using the gen*() functions below, call the
        // appropriate init*() function to correctly initialize the seed given the
        // offset to be generated.
        void initNation(size_t offset);

        void initRegion(size_t offset);

        void initOrder(size_t offset);

        void initSupplier(size_t offset);

        void initPart(size_t offset);

        void initCustomer(size_t offset);

        // Generate different types of records.
        void genNation(size_t index, dbgen::code_t &code);

        void genRegion(size_t index, dbgen::code_t &code);

        void genOrder(size_t index, dbgen::order_t &order);

        void genSupplier(size_t index, dbgen::supplier_t &supplier);

        void genPart(size_t index, dbgen::part_t &part);

        void genCustomer(size_t index, dbgen::customer_t &customer);

        dbgen::DBGenContext dbgenCtx_;
    };
} // namespace kumo::pollux::tpch
